package code.structure.manager.others
{
	import code.main.AppData;
	import code.main.core.net.YNet;
	import code.untils.GameConst;
	import code.untils.LogConst;
	import code.untils.NetConst;
	import code.untils.SwitchConfig;
	import code.untils.SystemFunction;
	
	import com.patience.net.NetConst;
	
	import flash.events.IOErrorEvent;
	import flash.net.URLLoader;
	import flash.utils.getTimer;
	
	
	
	/**
	 *统计管理器
	 * @author Yuri
	 *
	 */
	public class StatisticsManager
	{
		
		/**
		 * 记录日志
		 * @param	act	动作
		 * @param	tid 
		 * @param	item
		 * @param	value
		 * @param	value2
		 */
		public static function writeLog(act:String, tid:* = null, item:* = null, value:int = 0, value2:int = 0):void
		{
			if(!SwitchConfig.isRecordLog) return;
			//var data:Object = { "act":act, "tid":tid, "item":item, "value":value, "value2":value2 };
			var arr:Array = ["System", "SendProLog", [act, value, value2, tid, item]];
			var requestObj:Object = {};
			requestObj.command = 0;
			requestObj.requestid = SystemFunction.packId;
			requestObj.advanceTime = 0;
			requestObj.actionTime = SystemFunction.serverTime;
			
			var cmd:Object = {};
			cmd.id = SystemFunction.cmdId;
			cmd.timer = 0;
			cmd.request = arr;
			var uL:URLLoader = YNet.getIntance().httpSend("", [requestObj, cmd], AppData.logUrl, false, null, com.patience.net.NetConst.METHOD_FILE);
			if(uL){
				uL.addEventListener(IOErrorEvent.IO_ERROR,onIoerrorListener);
			}
		}
		
		protected static function onIoerrorListener(event:IOErrorEvent):void
		{
			// TODO Auto-generated method stub
			var urlLoader:URLLoader = event.currentTarget as URLLoader;
			urlLoader.removeEventListener(IOErrorEvent.IO_ERROR,onIoerrorListener);
			trace("日志网络IOErrorEvent");
		}
	}
}